package com.lib76.socket.model.protocol;

import java.util.ArrayList;
import java.util.List;

/**
 * ���Ľṹ����
 * @author �ź�
 *
 */
public class SocketProtocol {

	private String code;
	private String name;
	private Integer timeout;
	private String requestCommand;
	private String responseCommand;
	private String requestType;
	private String responseType;
	
	private List<SocketProtocolParameter> requestParameters;
	private List<SocketProtocolParameter> responseParameters;
	
	public SocketProtocol(){
		requestParameters = new ArrayList<SocketProtocolParameter>();
		responseParameters = new ArrayList<SocketProtocolParameter>();
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getTimeout() {
		return timeout;
	}
	public void setTimeout(Integer timeout) {
		this.timeout = timeout;
	}
	public String getRequestCommand() {
		return requestCommand;
	}
	public void setRequestCommand(String requestCommand) {
		this.requestCommand = requestCommand;
	}
	public String getResponseCommand() {
		return responseCommand;
	}
	public void setResponseCommand(String responseCommand) {
		this.responseCommand = responseCommand;
	}
	public String getRequestType() {
		return requestType;
	}
	public void setRequestType(String requestType) {
		this.requestType = requestType;
	}
	public String getResponseType() {
		return responseType;
	}
	public void setResponseType(String responseType) {
		this.responseType = responseType;
	}
	public List<SocketProtocolParameter> getRequestParameters() {
		return requestParameters;
	}
	public void setRequestParameters(List<SocketProtocolParameter> requestParameters) {
		this.requestParameters = requestParameters;
	}
	public List<SocketProtocolParameter> getResponseParameters() {
		return responseParameters;
	}
	public void setResponseParameters(
			List<SocketProtocolParameter> responseParameters) {
		this.responseParameters = responseParameters;
	}
	public int requestBodyLength(){
		int length =0;
		for(SocketProtocolParameter parameter:requestParameters){
			if(parameter.getLength() != null){
				length = length + parameter.getLength();
			}
		}
		return length;
	}
	public int responseBodyLength(){
		int length =0;
		for(SocketProtocolParameter parameter:responseParameters){
			if(parameter.getLength() != null){
				length = length + parameter.getLength();
			}
		}
		return length;
	}
}
